﻿using System;
using System.IO;

namespace ErrorDumper.PropertyExtracting {
    public class FileNotFoundExceptionPropertyExtractor : IExceptionPropertyExtractor {

        public void ExtractProperties(object instance, ExceptionPropertyCollection properties) {
            if (instance == null)
                throw new ArgumentNullException("instance");
            if (properties == null)
                throw new ArgumentNullException("properties");

            var exception = instance as FileNotFoundException;
            if (exception == null)
                return;

            if (!properties.Contains("FileName"))
                properties["FileName"] = exception.FileName;
        }
    }
}